package com.ck.notify;

public class Person {

    private String name;

    private int age;

    private boolean isEmpty = true;

    public synchronized void push(String name, int age) {
        try {
            while(!isEmpty){
                this.wait();
            }

            this.name = name;
            Thread.sleep(10);
            this.age = age;

            isEmpty = false;
            this.notifyAll();
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    public synchronized void pop(){
        try {
            while(isEmpty){
                this.wait();
            }

            Thread.sleep(10);
            System.out.println(this.name+"---"+this.age);
            isEmpty = true;
            this.notifyAll();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
